package cn.hdu.liang.ch1;

import java.io.File;
import java.io.FileFilter;

/**
 * 1.2.1查询当前目录下所有的隐藏文件
 */

public class FindHidden {
    public static void main(String[] args) {
        findHidden();
        System.out.println("=======Java8=======");
        findHiddenInJava8();
    }

    public static void findHidden() {
        File[] hiddenFiles = new File(".").listFiles(new FileFilter() {
            @Override
            public boolean accept(File pathname) {
                return pathname.isHidden();
            }
        });
        displayHidden(hiddenFiles);
    }

    public static void findHiddenInJava8() {
        File[] hiddenFiles = new File(".").listFiles(File::isHidden);
        displayHidden(hiddenFiles);
    }

    public static void displayHidden(File[] hiddenFiles) {
        for(File hiddenFile : hiddenFiles) {
            System.out.println(hiddenFile.getName());
        }
    }
}
